package com.example.moblie2021606143cwj0408;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity5 extends AppCompatActivity {

    private TextView tvMainTitle5;
    private TextView tvMain5;
    private TextView tvMain6;
    private TextView tvMain7;
    private EditText edt4;
    private Button btn3;
    private TextView tvResult3;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main5);
        initView();
       btn3.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               String string = edt4.getText().toString();
               int num=Integer.valueOf(string).intValue();
               double a = 5*(num - 39)/9;
               String b = String.format("%.3f", a);
               tvResult3.setText("摄氏度为"+b);
           }
       });


    }

    private void initView() {
        tvMainTitle5 = findViewById(R.id.tv_main_title5);
        tvMain5 = findViewById(R.id.tv_main_5);
        tvMain6 = findViewById(R.id.tv_main6);
        tvMain7 = findViewById(R.id.tv_main_7);
        edt4 = findViewById(R.id.edt4);
        btn3 = findViewById(R.id.btn3);
        tvResult3 = findViewById(R.id.tv_result3);
    }
}